package com.machine.bootstatemachine.machine;

import com.machine.bootstatemachine.domain.Order;
import com.machine.bootstatemachine.enums.OrderEventEnum;
import com.machine.bootstatemachine.enums.OrderStatueEnum;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.statemachine.persist.DefaultStateMachinePersister;
import org.springframework.statemachine.persist.StateMachinePersister;

/**
 * @Author daijinwu01
 * @Date 2021/12/27
 */
@Slf4j
@Configuration
public class OrderPersistConfiguration {

    @Autowired
    private OrderStateMachinePersist orderStateMachinePersist;

    @Bean
    public StateMachinePersister<OrderStatueEnum, OrderEventEnum, Order> orderStateMachinePersister() {
        log.info("状态");
        return new DefaultStateMachinePersister<>(orderStateMachinePersist);
    }

}
